<template>
  <a-popconfirm
    title="确定要删除该项?"
    ok-text="确定"
    cancel-text="取消"
    @confirm="confirm"
    v-model:open="open"
  >
    <a-button type="link" style="padding: 4px 6px" :loading="loading">
      删除
    </a-button>
  </a-popconfirm>
</template>
<script setup>
import { ref } from 'vue'
import { removeStructTable } from '@/api/db.js'
/**
 * 外部参数
 */
let props = defineProps({
  data: {
    type: Object,
    required: true,
  },
})
/**
 * 事件定义
 */
let emit = defineEmits(['operated'])
/**
 * 全局
 */
// let { update } = useDataSourceManager()
/**
 * 操作
 */
let loading = ref(false)
let open = ref(false)
// let dbType = useDbType()
async function confirm() {
  loading.value = true
  try {
    await removeStructTable({
      id: props.data.id,
    })
    open.value = false
    emit('operated')
  } catch (e) {
    console.log(e)
  }
  loading.value = false
}
</script>
<style lang="less" scoped></style>
